{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[119 255  22]\n",
      "[121 255  48]\n",
      "[120 255  47]\n",
      "[ 72  37 116]\n",
      "[0 0 0]\n",
      "[110 255   3]\n",
      "[ 60 255  10]\n",
      "[104 200 111]\n"
     ]
    }
   ],
   "source": [
    "import cv2\n",
    "import numpy as np\n",
    "from matplotlib import pyplot as plt\n",
    "\n",
    "# cap = cv2.VideoCapture(0)\n",
    "# while(1):\n",
    "#     # 获得图片\n",
    "#     ret, frame = cap.read()\n",
    "#     # 展示图片\n",
    "#     cv2.imshow(\"capture\", frame)\n",
    "#     if cv2.waitKey(1) & 0xFF == ord('q'):\n",
    "#         # 存储图片\n",
    "#         cv2.imwrite(\"red.jpg\", frame)\n",
    "#         break\n",
    "\n",
    "\n",
    "image=cv2.imread('1.jpg')\n",
    "HSV=cv2.cvtColor(image,cv2.COLOR_BGR2HSV)\n",
    "def getpos(event,x,y,flags,param):\n",
    "    if event==cv2.EVENT_LBUTTONDOWN: #定义一个鼠标左键按下去的事件\n",
    "        print(HSV[y,x])\n",
    "\n",
    "cv2.imshow(\"imageHSV\",HSV)\n",
    "cv2.imshow('image',image)\n",
    "cv2.setMouseCallback(\"imageHSV\",getpos)\n",
    "cv2.waitKey(0)\n",
    "cv2.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:opencv]",
   "language": "python",
   "name": "conda-env-opencv-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
